import { createWebHistory, createRouter } from 'vue-router';
// 后台管理子路由
const adminChildrenRoutes = [
  {
    path: 'user-management',
    name: 'UserManagement',
    component: () => import('@/views/Admin/UserManagement/index.vue'),
    meta: { title: '用户管理', icon: 'User'},
  },
  {
    path: 'library-location-management',
    name: 'LibraryLocationManagement',
    component: () => import('@/views/Admin/LibraryLocationManagement/index.vue'),
    meta: { title: '馆藏地管理', icon: 'Location' },
  },
  {
    path: 'journal-management',
    name: 'JournalManagement',
    component: () => import('@/views/Admin/JournalManagement/index.vue'),
    meta: { title: '期刊管理', icon: 'Location' },
  },
  {
    path: 'directory-management',
    name: 'DirectoryManagement',
    component: () => import('@/views/Admin/DirectoryManagement/index.vue'),
    meta: { title: '目录管理', icon: 'Location' },
  },
  {
    path: 'borrow-management',
    name: 'BorrowManagement',
    component: () => import('@/views/Admin/BorrowManagement/index.vue'),
    meta: { title: '借阅管理', icon: 'Notebook' },
  },
  {
    path: 'entrustment-management',
    name: 'EntrustmentManagement',
    component: () => import('@/views/Admin/EntrustmentManagement/index.vue'),
    meta: { title: '委托管理', icon: 'Document' },
  },
  {
    path: 'fine-management',
    name: 'FineManagement',
    component: () => import('@/views/Admin/FineManagement/index.vue'),
    meta: { title: '罚款管理', icon: 'Money' },
  },
  {
    path: 'annual-subscription',
    name: 'AnnualSubscription',
    component: () => import('@/views/Admin/AnnualSubscription/index.vue'),
    meta: { title: '年度征订', icon: 'Money' },
  },
  // 反馈管理路由
  {
    path: 'feedback-management',
    name: 'FeedbackManagement',
    component: () => import('@/views/Admin/FeedbackManagement/index.vue'),
    meta: { title: '反馈管理', icon: 'Message' },  // 你可以使用合适的图标
  },
  // 常量设置路由
  {
    path: 'set-management',
    name: 'SetManagement',
    component: () => import('@/views/Admin/UtilsManagement/index.vue'),
    meta: { title: '常量设置管理', icon: 'Message' },  // 你可以使用合适的图标
  },

];

// 用户导航子路由
const userChildrenRoutes = [
  {
    path: 'search',
    name: 'Search',
    component: () => import('@/views/User/Search/index.vue'),
    meta: { title: '全馆检索' },
  },
  {
    path: 'entrustment',
    name: 'Entrustment',
    component: () => import('@/views/User/Entrustment/index.vue'),
    meta: { title: '委托借阅' },
  },
  {
    path: 'borrow-records',
    name: 'BorrowRecords',
    component: () => import('@/views/User/BorrowRecords/index.vue'),
    meta: { title: '借阅记录' },
  },
  {
    path: 'feedback',
    name: 'Feedback',
    component: () => import('@/views/User/Feedback/index.vue'),
    meta: { title: '反馈' },
  },
  {
    path: 'profile',
    name: 'Profile',
    component: () => import('@/views/User/Profile/index.vue'),
    meta: { title: '我的信息' },
  },
];

// 主路由
const routes = [
  // 登录路由
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login.vue'),
  },
  // 后台管理路由
  {
    path: '/',
    component: () => import('@/components/Home.vue'),
    meta: { title: 'Home' },
    children: adminChildrenRoutes,
  },
  // 用户路由
  {
    path: '/user',
    component: () => import('@/components/userHome.vue'),
    meta: { title: '用户页面' },
    children: userChildrenRoutes,
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});



export default router;
